package com.client.mapper;

import com.client.entity.auth.Authority;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AuthorityDao {
    //查询所有
    @Select("select * from authority ")
    List<Authority> queryAll();

    //按编号查询
    @Select("select * from authority where id = #{ id }")
    Authority queryById(@Param("id") long id);

    //查询
    @Select("select * from authority where operator_id = #{ operator_id } and command_id = #{ command_id }")
    Authority query(@Param("operator_id") long operator_id, @Param("command_id") long command_id);

    //按operator_id查询
    @Select("select * from authority where operator_id = #{ operator_id }")
    List<Authority> queryByOperator(@Param("operator_id") long operator_id);

    //按command_id查询
    @Select("select * from authority where command_id = #{ command_id }")
    List<Authority> queryByCommand(@Param("command_id") long command_id);

    //增加
    @Insert("insert into authority values( #{id},#{operator_id},#{command_id})")
    void add(@Param("id") long id, @Param("operator_id") long operator_id, @Param("command_id") long command_id);

    //按编号删除
    @Delete("delete from authority where id = #{id}")
    void deleteByName(@Param("id") long id);

    //删除所有
    @Delete("delete from authority")
    void deleteAll();


}
